package com.zzc.mcpclient.web;

import com.zzc.mcpclient.service.ChatService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class HelloController {
    @Autowired
    private ChatService chatService;
    @GetMapping("hello")
    public String hello(@RequestParam String msg) {
        return chatService.sendMessage(msg);
    }
    @GetMapping("chat")
    public Flux<String> chat(@RequestParam String msg, HttpServletResponse response) {
        StopWatch stopWatch = new StopWatch();
        response.setCharacterEncoding("UTF-8");
        return chatService.chat(msg);
    }
}
